{{template "common/header.html" .}}
{{template "common/nav.html" .}}

<section class="main">
    <div class="container">
        <div class="columns">
            <div class="column is-9">
                <div class="main-body">
                    <article class="article-item">

                        <div class="article-item-left">
                            <a href="{{baseUrl}}/user/{{.Article.User.Id}}" title="{{.Article.User.Nickname}}"
                               target="_blank">
                                <div class="avatar is-rounded"
                                     style="background-image:url('{{.Article.User.Avatar}}')"></div>
                            </a>
                        </div>

                        <div class="article-item-right">
                            <div class="article-title">
                                <a href="{{baseUrl}}/article/{{.Article.ArticleId}}">{{.Article.Title}}</a>
                            </div>

                            <div class="article-meta">
                                <span class="article-meta-item"><a
                                            href="{{baseUrl}}/user/{{.Article.User.Id}}">{{.Article.User.Nickname}}</a></span>
                                {{if .Article.Category}}
                                    <span class="article-meta-item"><a
                                                href="{{categoryArticlesUrl .Article.Category.CategoryId 1}}">{{.Article.Category.CategoryName}}</a></span>
                                {{end}}
                                {{if .Article.Tags}}
                                    {{range .Article.Tags}}
                                        <span class="article-meta-item"><a
                                                    href="{{tagArticlesUrl .TagId 1}}">{{.TagName}}</a></span>
                                    {{end}}
                                {{end}}
                                <span class="article-meta-item"><time datetime="{{prettyTime .Article.CreateTime}}"
                                                                      itemprop="datePublished">{{prettyTime .Article.CreateTime}}</time></span>
                            </div>

                            <div class="article-tool">
                                {{if .CurrentUser}}
                                    {{if eq .CurrentUser.Id .Article.User.Id}}
                                        <span><i class="iconfont icon-delete"></i><a
                                                    href="javascript:delArticle({{.Article.ArticleId}})">删除</a></span>
                                        <span><i class="iconfont icon-edit"></i><a
                                                    href="{{baseUrl}}/article/edit/{{.Article.ArticleId}}">修改</a></span>
                                    {{end}}
                                {{end}}
                                <span><i class="iconfont icon-favorite"></i><a
                                            href="javascript:addFavorite({{.Article.ArticleId}})">收藏</a></span>
                            </div>
                        </div>

                        <div class="article-content content">
                            {{.Article.Content}}
                        </div>

                        <div class="article-footer">

                            <blockquote>
                                <ul>
                                    {{if .Article.SourceUrl}}
                                        {{/*
                                            <li>
                                                <strong>原文地址：</strong>
                                                <a href="{{.Article.SourceUrl}}" target="_blank"
                                                   rel='external nofollow'>{{.Article.SourceUrl}}</a>
                                            </li>
                                            */}}
                                    {{else}}
                                        {{/*
                                            <li>
                                                <strong>本文链接：</strong>
                                                <a href="{{baseUrl}}/article/{{.Article.ArticleId}}"
                                                   title="{{.Article.Title}}"
                                                   target="_blank" rel="external">{{baseUrl}}
                                                    /article/{{.Article.ArticleId}}</a>
                                            </li>
                                            */}}
                                        <li>
                                            <strong>版权声明： </strong>所有文章除特别声明外，均采用 <a
                                                    href="http://creativecommons.org/licenses/by/4.0/deed.zh"
                                                    target="_blank"
                                                    rel="external nofollow">CC BY 4.0 CN协议</a> 许可协议。转载请注明出处！
                                        </li>
                                    {{end}}
                                    <li class="post-copyright-link hidden-xs">
                                        <strong>免责声明：</strong>
                                        我们尊重原创，也注重分享。版权原作者所有，如有侵犯您的权益请及时联系（<a
                                                href="mailto:mlog1@qq.com">mlog1@qq.com</a>），我们将在24小时之内删除。
                                    </li>
                                </ul>
                            </blockquote>

                        </div>

                        <!-- 展示广告-横幅 -->
                        <ins class="adsbygoogle"
                             style="display:block"
                             data-ad-client="ca-pub-5683711753850351"
                             data-ad-slot="1742173616"
                             data-ad-format="auto"
                             data-full-width-responsive="true"></ins>
                        <script>
                          (adsbygoogle = window.adsbygoogle || []).push({});
                        </script>

                    </article>

                    {{template "comment/index.html" .}}

                </div>
            </div>
            <div class="column is-3">
                <div class="main-aside">

                    <div class="widget">
                        <div class="header">{{.Article.User.Nickname}}</div>
                        <div class="content">
                            <div>
                            <span>
                                <i class="iconfont icon-username"></i>
                                <a href="{{baseUrl}}/user/{{.Article.User.Id}}">{{.Article.User.Nickname}}</a>
                            </span>
                            </div>
                            <a href="{{baseUrl}}/user/{{.Article.User.Id}}" title="{{.Article.User.Nickname}}"
                               target="_blank">
                                <div class="avatar"
                                     style="width:150px; height: 150px; background-image: url('{{.Article.User.Avatar}}');"></div>
                            </a>
                            {{if .Article.User.Description}}
                                <p>{{.Article.User.Description}}</p>
                            {{end}}
                        </div>
                    </div>
                    {{if eq .Article.User.Type 1}}
                        <div class="widget">
                            <div class="header">关注公众号</div>
                            <div class="content">
                                <img src="https://open.weixin.qq.com/qr/code?username={{.Article.User.Username}}"/>
                            </div>
                        </div>
                    {{end}}

                    {{if .NewestArticles}}
                        <div class="widget">
                            <div class="header">最新文章</div>
                            <div class="content">
                                <ul>
                                    {{range .NewestArticles}}
                                        <li>
                                            <a href="{{articleUrl .ArticleId}}" title="{{.Title}}"
                                               target="_blank">{{.Title}}</a>
                                        </li>
                                    {{end}}
                                </ul>
                            </div>
                        </div>
                    {{end}}

                    {{if .RelatedArticles}}
                        <div class="widget">
                            <div class="header">相关文章</div>
                            <div class="content">
                                <ul>
                                    {{range .RelatedArticles}}
                                        <li>
                                            <a href="{{articleUrl .ArticleId}}" title="{{.Title}}"
                                               target="_blank">{{.Title}}</a>
                                        </li>
                                    {{end}}
                                </ul>
                            </div>
                        </div>
                    {{end}}

                    <!-- 正方形 -->
                    <ins class="adsbygoogle"
                         style="display:block"
                         data-ad-client="ca-pub-5683711753850351"
                         data-ad-slot="1787062187"
                         data-ad-format="auto"
                         data-full-width-responsive="true"></ins>
                    <script>
                      (adsbygoogle = window.adsbygoogle || []).push({});
                    </script>
                </div>
            </div>
        </div>
    </div>
</section>


{{/*高亮*/}}
<link href="//cdn.bootcss.com/highlight.js/8.0/styles/monokai_sublime.min.css" rel="stylesheet">
<script src="//cdn.bootcss.com/highlight.js/8.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad()</script>

<script type="text/javascript">
  function delArticle(articleId) {
    httpPost('{{baseUrl}}/article/delete/' + articleId)
      .then(function (data) {
        alert('删除成功')
      }, function (response) {
        alert(response.message)
      })
  }

  function addFavorite(articleId) {
    httpPost('{{baseUrl}}/article/favorite/' + articleId)
      .then(function (data) {
        alert('收藏成功')
      }, function (response) {
        console.error(response)
      })
  }
</script>
{{template "common/footer.html" .}}
